package com.zhuss.meeting.processor;

import com.zhuss.bean.bo.meeting.apply.RevokeApplyBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.enums.LogActionEnum;
import com.zhuss.enums.MeetRoomCheck;
import com.zhuss.enums.MoudleEnum;
import com.zhuss.exception.WpsException;
import com.zhuss.meeting.db.dao.ext.MeetingApplyDao;
import com.zhuss.meeting.db.entity.MeetingRoomApply;
import com.zhuss.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/18 15:49
 */
@Component("applyRevoke")
public class ApplyRevoke extends AbstractProcessor<Object, RevokeApplyBo> implements Processor<Object, RevokeApplyBo> {

    @Autowired
    private MeetingApplyDao meetingApplyDao;

    @Override
    public Object process(RevokeApplyBo bo) throws WpsException {
        MeetingRoomApply m = new MeetingRoomApply();
        m.setApplyId(bo.getApplyId());
        m.setStatus(MeetRoomCheck.待提交.key());
        meetingApplyDao.updateByPrimaryKeySelective(m);
        return null;
    }

    @Override
    public Object log(RevokeApplyBo param) throws WpsException {
        OpLog record = new OpLog();
        record.setMoudle(MoudleEnum.会务.key());
        record.setAction(LogActionEnum.会议室申请提交.key());
        record.setTargetId(param.getApplyId());
        record.setContent("参数: " + JsonUtil.toJson(param));
        record.setReason(param.getExceptionReason());

        record.setCreatorId(param.getConcurrentUserId());
        record.setCreator(param.getConcurrentUserName());
        record.setCreateTime(new Date());
        log(record);
        return null;
    }

    @Override
    public void check(RevokeApplyBo revokeApplyBo) throws WpsException {

    }
}
